<?php
/**
 * PHP Framework Domain Model Storage class
 *
 * TODO: Add support for various storage types
 *
 * @author Andrew <andrew@vitche.com>
 * @author Frozen Rain <frozenrain@mail.ru>
 **/

class Storage {

    /**
     * @var mixed Stores a persistent storage connection
     **/
    private static $_connection = null;

    /**
     * @var string Stores storage type
     **/
    private static $_type = null;

    /**
     * Configures storage to use MySQL connection
     **/
    public static function connectMySQL($host, $catalog, $user, $password) {

        Storage::$_type = 'mysql';

        Storage::$_connection = ADONewConnection('mysql');
        //Storage::$_connection->debug = true;
        $res = Storage::$_connection->Connect($host, $user, $password, $catalog, false);
        Storage::$_connection->Execute("SET NAMES utf8");
        return $res;
    }

    /**
     * Executes an SQL statement on a relational storage
     * @param string $strSQLQuery An SQL statement to be executed
     **/
    public static function executeSQL($strSQLQuery) {
        return Storage::$_connection->Execute($strSQLQuery);
    }

    /**
     * TODO: Implement this
     **/
    public static function executeXPath($strXPathQuery) {
    }
}
?>